package me.itsoo.artemis.framework.repository.builder;

import me.itsoo.artemis.framework.repository.executor.BoundSql;

import java.util.Objects;

/**
 * AbstractSqlBuilder
 *
 * @author zxy
 * @version 0.0.1
 * @since 2023/5/18
 */
public abstract class AbstractSqlBuilder implements SqlBuilder, BuilderBoundSqlFactory {

    @Override
    public String getBuilderCommand() {
        return null;
    }

    @Override
    public Object[] getBuilderArgs() {
        return new Object[0];
    }

    @Override
    public String toString() {
        return this.getBuilderCommand();
    }

    @Override
    public BoundSql getBoundSql(SqlBuilder sqlBuilder) {
        String sql = "";
        Object[] args = new Object[0];

        if (Objects.nonNull(sqlBuilder)) {
            sql = sqlBuilder.getBuilderCommand();
            args = sqlBuilder.getBuilderArgs();
        }

        return BoundSql.create(sql, args);
    }
}
